/**
 * @file 处理请求接口函数
 */

import axios from '@/utils/Request.ts';

export async function get(url: string, params?: any) {
  const res = await axios.get(url, {
    params,
  });
  if (res.code === 0 || res.code === 1000) {
    return res;
  }
}

export async function post(url: string, params: any) {
  const res = await axios.post(url, params);
  if (res.code === 0 || res.code === 1000) {
    return res;
  }
}

export async function uploadPost(url: string, params: any) {
  const res = await axios.post(url, params, {
    headers: {
      // 表示上传的是文件,而不是普通的表单数据
      'Content-Type': 'multipart/form-data',
    },
  });
  if (res.code === 0) {
    return res;
  }
}
